#pragma once
#ifndef __PARSER_H__
#define __PARSER_H__

#include "Token.h"
#include "NezhaFoundation.h"

class cLexer;

class cParser
{
public:
	cParser();
	cParser( cLexer* lexer, const _string& fileName );
	virtual ~cParser();

	void SetLexer( cLexer* lexer );

	void SetFileName( const _string& fileName );

	bool ExpectTokenString( const char* str );
	bool ExpectTokenType( int type );

	_string ParseString();
	bool ParseString( _string* str );

	_string ParseStringWithKeyword(const _string& keyword);
	bool ParseStringWithKeyword( _string* str ,const _string& keyword);

	cLexer* GetLexer() const;

	const char* GetFileName() const;

	int GetLineNum() const;

protected:

	cLexer* mpLexer;

	std::string mFileName;

	cToken mToken;
};

inline void cParser::SetLexer( cLexer* lexer )
{
	mpLexer = lexer;
}

inline void cParser::SetFileName( const _string& fileName )
{
	mFileName = fileName;
}

inline cLexer* cParser::GetLexer() const
{
	return mpLexer;
}

inline int cParser::GetLineNum() const
{
	return mToken.mLine;
}


inline const char* cParser::GetFileName() const
{
	return mFileName.c_str();
}

#endif // __PARSER_H__